package cn.tedu.csmall.stock.webapi.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface StockMapper {
    // 修改（减少）指定商品的库存
    @Update("UPDATE stock_tbl SET count=count-#{reduceCount} " +
            " WHERE commodity_code=#{commodityCode} AND count>=#{reduceCount}")
    int updateStockCount(@Param("commodityCode") String commodityCode,
                         @Param("reduceCount") Integer reduceCount);
}
